<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>
<body>
    <div id="app"></div>
</body>
<script>
    const app = Vue.createApp({
        data(){
            return{
                count:1
            }
        },
        methods:{
            onclick(){
                this.count+=1;
            }
        },
        // 侦听器
        watch:{
            // 接受两个参数,一个是改变之后的值,一个是改变之前的值
            count(current, prev){
                console.log(current," ",prev)
            }
        },
        template:`<h2 @click="onclick">{{count}}</h2>`
    })
    const vm = app.mount("#app")
</script>
</html>